Pharmaceutical analysis based on the Electronic Patient Record